extends "../kelifulan-2/kelifulan-2.gd"


func _extInit():
	._extInit()
	lv = 3             #等级的设置
	addSkill("<先手>每{cd}秒向距离最远的敌人投掷一个大宝贝，使其<眩晕>2秒，在效果结束时，\n若目标身边存在其他队友，则随机弹向其队友，最多弹射4次", "所罗门传说", "slmcs", 8)

func _castCdSkill(id):
	._castCdSkill(id)
	if id=="slmcs":
		slmcs()

func slmcs():
	utils.createSkillTextEff("所罗门传说", position)
	var chas=getAllChas(1)
	chas.sort_custom(self,"sortByDistanceDesc")
	createFlyEff(sprcPos, chas[0], "sk_4_1_2")
	chas[0].addBuff(b_tantanle.new())
	
func _onBattleStart():
	._onBattleStart()
	slmcs()

#弹弹乐
class b_tantanle:
	extends "../../../azurlane_ctrl/AzurBuff.gd"
	var num = 1
	var maxNum = 4
	func _init(num = 1, maxNum = 4):
		attInit()
		id = "b_tantanle"
		life = 2
		self.num = num
		self.maxNum = maxNum
		isNegetive=true
	func _connect():
		._connect()
		masCha.aiOn = false
		eff2 = sys.newEff("animEff", masCha.position)
		eff2.setImgs(sys.getBasePath() + "/eff/yunXuan", 5, true)
		eff2.scale *= 1
		eff2.normalSpr.position=Vector2(0, -70)
	var eff2
	func _process(delta):
		if masCha != null && is_instance_valid(eff2):
			eff2.position = masCha.position
	func _del():
		._del()
		if is_instance_valid(eff2):
			eff2.queue_free()
		masCha.aiOn = true
		if num >= maxNum:
			return
		var chas = masCha.getCellChas(masCha.cell, 2, 2)
		if chas == null || chas.size() == 0:
			return
		chas.shuffle()
		var t
		for i in chas:
			if i != masCha && not i.isDeath && not i.hasBuff("b_tantanle"):
				t = i
		if t != null:
			var d:Eff = masCha.newEff("sk_4_1_2",masCha.sprcPos)
			d._initFlyCha(t)
			yield(d,"onReach")
			t.addBuff(b_tantanle.new(num + 1))